#ifndef _FLASH_H
#define _FLASH_H


#include "sys_hc32f460.h"

#define F460_FLASH_SIZE 512
#define F460_SECTOR_SIZE	8192
#define F460_FLASH_BASE 0x00000000 
#define FLASH_1K_SIZE			1024
#define TOTAL_FLASH_SIZE  		512*1024
#define BOOTLOADER_FLASH_SIZE	24*1024
#define APPLICATION_FLASH_SIZE  200*1024
#define DOWNLOAD_FLASH_SIZE		APPLICATION_FLASH_SIZE
#define APPLICATION_ADDR		0x6000
#define DOWNLOAD_ADDR			(BOOTLOADER_FLASH_SIZE + APPLICATION_FLASH_SIZE)
#define DOWNLOAD_FILEINFO_ADDR	(BOOTLOADER_FLASH_SIZE + APPLICATION_FLASH_SIZE + DOWNLOAD_FLASH_SIZE)

void F460FLASH_Write(u32 WriteAddr,u8 *pBuffer,u16 NumToWrite);
void F460FLASH_Read(u32 ReadAddr,u8 *pBuffer,u16 NumToRead);

void F460FLASH_Sector_Erase(u32 WriteAddr,u32 num);
void F460FLASH_Write1(u32 WriteAddr,u8 *pBuffer,u16 NumToWrite);

#endif
